package cn.tedu.thread;

public class DaemonThreadDemo {
    public static void main(String[] args) {
        Thread rose = new Thread(){
            public void run(){
                for (int i=0;i<5;i++){
                    System.out.println("守护线程");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        System.out.println("阻塞抛出异常");
                    }
                    System.out.println("rose:啊啊啊啊啊啊AAAAAAAaaaaa....");
                    System.out.println("噗通");

                }
            }
        };
        Thread jack = new Thread(){
            public void run(){
                while (true){
                    System.out.println("jack: you jump!jump!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        System.out.println("使该线程阻塞.");
                    }

                }
            }
        };
        rose.start();
        jack.setDaemon(true);
        jack.start();
    }
}
